package br.edu.ufcg.lp2;
/**
 * This class represents a tag,
 * which has a name (String)
 * 
 * @author João Pedro Leôncio <joopeeds@gmail.com>
 * @author Franco Stefano <stefano.tejo@gmail.com>
 * @author Fellype Cavalcante <fellype.cavalcante@gmail.com>
 */
public class Tag /*implements Comparable<Tag>*/{

	private String name;
	//private double rating;
	
	/**
	 * 
	 * @param name
	 * 		The name of the tag
	 * @throws Exception
	 * 		If the name is an empty string
	 */
	public Tag(String name) throws Exception{
		setName(name);
		//setRating(5);
	}

	/**
	 * Return the name of the tag
	 * @return String
	 * 		The name of the tag
	 */
	public String getName() {
		return name;
	}

	/**
	 * Changes the name of the tag
	 * @param name
	 * 		The name of the tag
	 * @throws Exception
	 * 		If the name is an empty string
	 */
	public void setName(String name) throws Exception {
		if(name.trim().length() == 0) throw new Exception("Name cannot be empty");
		this.name = name;
	}

	/*
	public double getRating() {
		return rating;
	}
	
	
	
	public void setRating(double rating) throws Exception{
		if(rating < 0 || rating >10) throw new Exception("Rating must be between 0 and 10");
		this.rating = rating;
	}
	*/
	

	@Override
	public boolean equals(Object obj) {
		if (getClass() != obj.getClass()) return false;
		return name.equals(((Tag) obj).getName());
	}

	@Override
	public String toString() {
		return "Tag [name = " + name + "]";
	}

	/*
	@Override
	public int compareTo(Tag o) {
		return (int) (getRating()*100 - o.getRating()*100);
	}


	public void like() throws Exception {
		setRating(rating + 1);
	}
	public void halflike() {
		//......
	}
	public void hate() throws Exception {
		setRating(rating - 1);
	}
	*/
	
}
